package com.gateway.loadBalance.Random;

import com.gateway.loadBalance.AbstractLoadBalance;
import com.gateway.loadBalance.Invoker;

import java.util.List;
import java.util.Random;

/**
 * @author Huangkai
 */
public class SimpleRandomLoadBalance extends AbstractLoadBalance {

    public SimpleRandomLoadBalance(List<Invoker> invokers) {
        super(invokers);
    }

    @Override
    protected Invoker doSelect() {
        return getInvokers().get(new Random().nextInt(getInvokers().size()));
    }

    @Override
    public List<Invoker> getInvokers() {
        return invokerList;
    }
}
